package edu.zut.cs.software.practice;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;


/**
 * 
 * @author 陈明阳
<<<<<<< HEAD
 * 
=======
 * @author 黄靖
>>>>>>> 05ca3405ac39cef5e837c5927862f04da93739e0
 *
 */
public class studentManagerImpl implements studentManager{
	
	private Connection conn=null;
	
	@Override
	public void add(student stu) throws SQLException {
		//1.建立数据库连接
		conn=JDBC.getConn();
		
		//2.定义SQL语句：向表中插入一条记录
		String sql="insert into student(id)values(?)";
		
		//3.创建PreparedStatement 对象，传入SQL语句
		PreparedStatement ps=conn.prepareStatement(sql);
		
		//4.向SQL语句传入参数
		ps.setString(1, stu.getId());
		
		
		//5.执行SQL语句
		ps.executeUpdate(); 
		
		//6.释放资源
		JDBC.free(null,ps,conn);
		
	}

}
